package com.example.demo.utils;

import com.example.demo.model.User;
import com.example.demo.model.json.ImageData;
import org.springframework.ui.Model;

import java.util.ArrayList;
import java.util.List;

public class CommonUtil {

    /**
     * 获取通用数据模型
     * */
    public  static void getCommonModel(Model model){
        List<ImageData> imagelist = new ArrayList<>();
        List<User> userlist = new ArrayList<>();
        for (int i = 1; i < 9; i++) {
            ImageData imageData=new ImageData("/images/00" + i + ".jpg","");
            imagelist.add(imageData);

            User user = new User(0L, "hello" + i, null, null);
            user.setAvater("/images/s0" + i + ".jpg");
            userlist.add(user);
        }

        User user_info = new User(0L, "wink-172");
        user_info.setAvater("/images/photo.jpg");
        user_info.setContent("wink-172");
        user_info.setContent2("努力做充满力量的人....");
        user_info.setContent3("性别：未知");


        model.addAttribute("imagelist", imagelist);//最新照片列表
        model.addAttribute("userList", userlist);//访客列表
        model.addAttribute("user", user_info);//个人资料
    }
}
